package com.jz;

import org.apache.commons.lang3.RandomUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.Random;

/**
 * Created by Hasee on 2022-03-03.
 */
@RestController
public class TestController {

    @Autowired
    private TestMapper testMapper;

    /*@GetMapping("test")
    public List<UserVo> test(){
        List<UserVo> userVos = testMapper.queryUser();
        System.out.println(userVos);
        return userVos;
    }
    @GetMapping("testInsert")
    public int testInsert(Integer id,String name){
        UserVo userVo =new UserVo();
        userVo.setId(id);
        userVo.setName(name);
        int user = testMapper.insertUser(userVo);
        return user;
    }*/

    @GetMapping("fenbiao")
    public void fenbiao(){
       /* for (int i = 1; i <11 ; i++) {
            int a =  new Random().nextInt(10);
            UserVo userVo =new UserVo(i,i+1,"张三","测试地址",a);
            testMapper.insertUser(userVo);
        }*/

        UserVo userVo =new UserVo(1,10,"张三","测试地址",18);
        testMapper.insertUser(userVo);
    }

    @GetMapping("addAddress")
    public void addAddress(){
       /* for (int i = 1; i <11 ; i++) {
            int a =  new Random().nextInt(10);
            UserVo userVo =new UserVo(i,i+1,"张三","测试地址",a);
            testMapper.insertUser(userVo);
        }*/
        AddressVo addressVo =new AddressVo(10,"张三");
        testMapper.addAddress(addressVo);
    }

    @GetMapping("queryAll")
    public List<UserVo> queryAll(){
       List<UserVo> userVoList= testMapper.selectAll();
       return userVoList;
    }

    public static void main(String[] args) {
        int a =  new Random().nextInt(10);
        System.out.println(a);
    }
}
